diff options
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r-- | clang/lib/Sema/HeuristicResolver.cpp | 5 | ||||
-rw-r--r-- | clang/lib/Sema/Sema.cpp | 11 | ||||
-rw-r--r-- | clang/lib/Sema/SemaBase.cpp | 17 | ||||
-rw-r--r-- | clang/lib/Sema/SemaOpenACC.cpp | 25 | ||||
-rw-r--r-- | clang/lib/Sema/SemaOverload.cpp | 13 | ||||
-rw-r--r-- | clang/lib/Sema/SemaRISCV.cpp | 16 |
6 files changed, 52 insertions, 35 deletions
diff --git a/clang/lib/Sema/HeuristicResolver.cpp b/clang/lib/Sema/HeuristicResolver.cpp index cbdefaa..056e133 100644 --- a/clang/lib/Sema/HeuristicResolver.cpp +++ b/clang/lib/Sema/HeuristicResolver.cpp @@ -450,7 +450,12 @@ QualType HeuristicResolverImpl::resolveExprToType(const Expr *E) { if (const auto *CE = dyn_cast<CallExpr>(E)) { if (QualType Resolved = resolveTypeOfCallExpr(CE); !Resolved.isNull()) return Resolved; + + // Don't proceed to try resolveExprToDecls(), it would just call + // resolveTypeOfCallExpr() again. + return E->getType(); } + // Similarly, unwrapping a unary dereference operation does not work via // resolveExprToDecls. if (const auto *UO = dyn_cast<UnaryOperator>(E->IgnoreParenCasts())) { diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index 39fa25f..215ac18 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -2214,9 +2214,9 @@ void Sema::checkTypeSupport(QualType Ty, SourceLocation Loc, ValueDecl *D) { else PD << "expression"; - if (Diag(Loc, PD, FD) - << false /*show bit size*/ << 0 << Ty << false /*return*/ - << TI.getTriple().str()) { + if (Diag(Loc, PD) << false /*show bit size*/ << 0 << Ty + << false /*return*/ + << TI.getTriple().str()) { if (D) D->setInvalidDecl(); } @@ -2233,9 +2233,8 @@ void Sema::checkTypeSupport(QualType Ty, SourceLocation Loc, ValueDecl *D) { else PD << "expression"; - if (Diag(Loc, PD, FD) - << false /*show bit size*/ << 0 << Ty << true /*return*/ - << TI.getTriple().str()) { + if (Diag(Loc, PD) << false /*show bit size*/ << 0 << Ty << true /*return*/ + << TI.getTriple().str()) { if (D) D->setInvalidDecl(); } diff --git a/clang/lib/Sema/SemaBase.cpp b/clang/lib/Sema/SemaBase.cpp index 9b677f4..bf32491 100644 --- a/clang/lib/Sema/SemaBase.cpp +++ b/clang/lib/Sema/SemaBase.cpp @@ -58,13 +58,13 @@ SemaBase::SemaDiagnosticBuilder::getDeviceDeferredDiags() const { return S.DeviceDeferredDiags; } -Sema::SemaDiagnosticBuilder SemaBase::Diag(SourceLocation Loc, unsigned DiagID, - bool DeferHint) { +Sema::SemaDiagnosticBuilder SemaBase::Diag(SourceLocation Loc, + unsigned DiagID) { bool IsError = getDiagnostics().getDiagnosticIDs()->isDefaultMappingAsError(DiagID); bool ShouldDefer = getLangOpts().CUDA && getLangOpts().GPUDeferDiag && DiagnosticIDs::isDeferrable(DiagID) && - (DeferHint || SemaRef.DeferDiags || !IsError); + (SemaRef.DeferDiags || !IsError); auto SetIsLastErrorImmediate = [&](bool Flag) { if (IsError) SemaRef.IsLastErrorImmediate = Flag; @@ -83,16 +83,13 @@ Sema::SemaDiagnosticBuilder SemaBase::Diag(SourceLocation Loc, unsigned DiagID, } Sema::SemaDiagnosticBuilder SemaBase::Diag(SourceLocation Loc, - const PartialDiagnostic &PD, - bool DeferHint) { - return Diag(Loc, PD.getDiagID(), DeferHint) << PD; + const PartialDiagnostic &PD) { + return Diag(Loc, PD.getDiagID()) << PD; } SemaBase::SemaDiagnosticBuilder SemaBase::DiagCompat(SourceLocation Loc, - unsigned CompatDiagId, - bool DeferHint) { + unsigned CompatDiagId) { return Diag(Loc, - DiagnosticIDs::getCXXCompatDiagId(getLangOpts(), CompatDiagId), - DeferHint); + DiagnosticIDs::getCXXCompatDiagId(getLangOpts(), CompatDiagId)); } } // namespace clang diff --git a/clang/lib/Sema/SemaOpenACC.cpp b/clang/lib/Sema/SemaOpenACC.cpp index 3bb8080..ee9b2b3 100644 --- a/clang/lib/Sema/SemaOpenACC.cpp +++ b/clang/lib/Sema/SemaOpenACC.cpp @@ -2999,11 +2999,11 @@ bool SemaOpenACC::CreateReductionCombinerRecipe( BinOp = BinaryOperatorKind::BO_LT; break; case OpenACCReductionOperator::And: + BinOp = BinaryOperatorKind::BO_LAnd; + break; case OpenACCReductionOperator::Or: - // We just want a 'NYI' error in the backend, so leave an empty combiner - // recipe, and claim success. - CombinerRecipes.push_back({nullptr, nullptr, nullptr}); - return false; + BinOp = BinaryOperatorKind::BO_LOr; + break; } // If VarTy is an array type, at the top level only, we want to do our @@ -3068,8 +3068,21 @@ bool SemaOpenACC::CreateReductionCombinerRecipe( : CombinerFailureKind::Assignment}; } case OpenACCReductionOperator::And: - case OpenACCReductionOperator::Or: - llvm_unreachable("And/Or not implemented, but should fail earlier"); + case OpenACCReductionOperator::Or: { + // These are done as LHS = LHS && RHS (or LHS = LHS || RHS). So after the + // binop, all we have to do is the assignment. + if (!BinOpRes.isUsable()) + return {BinOpRes, CombinerFailureKind::BinOp}; + + // Build assignment. + ExprResult Assignment = SemaRef.BuildBinOp(SemaRef.getCurScope(), Loc, + BinaryOperatorKind::BO_Assign, + LHSDRE, BinOpRes.get(), + /*ForFoldExpr=*/false); + return {Assignment, Assignment.isUsable() + ? CombinerFailureKind::None + : CombinerFailureKind::Assignment}; + } case OpenACCReductionOperator::Invalid: llvm_unreachable("Invalid should have been caught above"); } diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 7da09e8..1f25111 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -13208,7 +13208,10 @@ void OverloadCandidateSet::NoteCandidates( auto Cands = CompleteCandidates(S, OCD, Args, OpLoc, Filter); - S.Diag(PD.first, PD.second, shouldDeferDiags(S, Args, OpLoc)); + { + Sema::DeferDiagsRAII RAII{S, shouldDeferDiags(S, Args, OpLoc)}; + S.Diag(PD.first, PD.second); + } // In WebAssembly we don't want to emit further diagnostics if a table is // passed as an argument to a function. @@ -13271,10 +13274,10 @@ void OverloadCandidateSet::NoteCandidates(Sema &S, ArrayRef<Expr *> Args, // inform the future value of S.Diags.getNumOverloadCandidatesToShow(). S.Diags.overloadCandidatesShown(CandsShown); - if (I != E) - S.Diag(OpLoc, diag::note_ovl_too_many_candidates, - shouldDeferDiags(S, Args, OpLoc)) - << int(E - I); + if (I != E) { + Sema::DeferDiagsRAII RAII{S, shouldDeferDiags(S, Args, OpLoc)}; + S.Diag(OpLoc, diag::note_ovl_too_many_candidates) << int(E - I); + } } static SourceLocation diff --git a/clang/lib/Sema/SemaRISCV.cpp b/clang/lib/Sema/SemaRISCV.cpp index c5ef0d5..b5f91a3 100644 --- a/clang/lib/Sema/SemaRISCV.cpp +++ b/clang/lib/Sema/SemaRISCV.cpp @@ -1445,21 +1445,21 @@ void SemaRISCV::checkRVVTypeSupport(QualType Ty, SourceLocation Loc, Decl *D, if (Info.ElementType->isSpecificBuiltinType(BuiltinType::Double) && !FeatureMap.lookup("zve64d")) - Diag(Loc, diag::err_riscv_type_requires_extension, D) << Ty << "zve64d"; + Diag(Loc, diag::err_riscv_type_requires_extension) << Ty << "zve64d"; // (ELEN, LMUL) pairs of (8, mf8), (16, mf4), (32, mf2), (64, m1) requires at // least zve64x else if (((EltSize == 64 && Info.ElementType->isIntegerType()) || MinElts == 1) && !FeatureMap.lookup("zve64x")) - Diag(Loc, diag::err_riscv_type_requires_extension, D) << Ty << "zve64x"; + Diag(Loc, diag::err_riscv_type_requires_extension) << Ty << "zve64x"; else if (Info.ElementType->isFloat16Type() && !FeatureMap.lookup("zvfh") && !FeatureMap.lookup("zvfhmin") && !FeatureMap.lookup("xandesvpackfph")) if (DeclareAndesVectorBuiltins) { - Diag(Loc, diag::err_riscv_type_requires_extension, D) + Diag(Loc, diag::err_riscv_type_requires_extension) << Ty << "zvfh, zvfhmin or xandesvpackfph"; } else { - Diag(Loc, diag::err_riscv_type_requires_extension, D) + Diag(Loc, diag::err_riscv_type_requires_extension) << Ty << "zvfh or zvfhmin"; } else if (Info.ElementType->isBFloat16Type() && @@ -1467,18 +1467,18 @@ void SemaRISCV::checkRVVTypeSupport(QualType Ty, SourceLocation Loc, Decl *D, !FeatureMap.lookup("xandesvbfhcvt") && !FeatureMap.lookup("experimental-zvfbfa")) if (DeclareAndesVectorBuiltins) { - Diag(Loc, diag::err_riscv_type_requires_extension, D) + Diag(Loc, diag::err_riscv_type_requires_extension) << Ty << "zvfbfmin or xandesvbfhcvt"; } else { - Diag(Loc, diag::err_riscv_type_requires_extension, D) << Ty << "zvfbfmin"; + Diag(Loc, diag::err_riscv_type_requires_extension) << Ty << "zvfbfmin"; } else if (Info.ElementType->isSpecificBuiltinType(BuiltinType::Float) && !FeatureMap.lookup("zve32f")) - Diag(Loc, diag::err_riscv_type_requires_extension, D) << Ty << "zve32f"; + Diag(Loc, diag::err_riscv_type_requires_extension) << Ty << "zve32f"; // Given that caller already checked isRVVType() before calling this function, // if we don't have at least zve32x supported, then we need to emit error. else if (!FeatureMap.lookup("zve32x")) - Diag(Loc, diag::err_riscv_type_requires_extension, D) << Ty << "zve32x"; + Diag(Loc, diag::err_riscv_type_requires_extension) << Ty << "zve32x"; } /// Are the two types RVV-bitcast-compatible types? I.e. is bitcasting from the |