github-actions[bot] wrote: <!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning: <details> <summary> You can test this locally with the following command: </summary> ``````````bash git-clang-format --diff ad23127222fe23e28ac3deaa16f3ae64d13b7b6f 2a1b0d2d99c9bc4595dfc98f250bf43d23a28093 -- clang/test/Sema/attr-nolock-wip.cpp clang/test/Sema/attr-nolock.cpp clang/test/Sema/attr-nolock2.cpp clang/test/Sema/attr-nolock3.cpp clang/include/clang/AST/Decl.h clang/include/clang/AST/Type.h clang/include/clang/Sema/Sema.h clang/lib/AST/ASTContext.cpp clang/lib/AST/Decl.cpp clang/lib/AST/Type.cpp clang/lib/AST/TypePrinter.cpp clang/lib/Sema/AnalysisBasedWarnings.cpp clang/lib/Sema/Sema.cpp clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaDeclAttr.cpp clang/lib/Sema/SemaDeclCXX.cpp clang/lib/Sema/SemaExpr.cpp clang/lib/Sema/SemaExprCXX.cpp clang/lib/Sema/SemaLambda.cpp clang/lib/Sema/SemaOverload.cpp clang/lib/Sema/SemaType.cpp `````````` </details> <details> <summary> View the diff from clang-format here. </summary> ``````````diff diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index de21561ce5..779c72ab63 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -4360,8 +4360,8 @@ class FunctionProtoType final // hasFunctionEffects() is true. // // * Optionally a Qualifiers object to represent extra qualifiers that can't - // be represented by FunctionTypeBitfields.FastTypeQuals. Present if and only - // if hasExtQualifiers() is true. + // be represented by FunctionTypeBitfields.FastTypeQuals. Present if and + // only if hasExtQualifiers() is true. // // The optional FunctionTypeExtraBitfields has to be before the data // related to the exception specification since it contains the number @@ -4435,8 +4435,7 @@ public: bool requiresFunctionProtoTypeExtraBitfields() const { return ExceptionSpec.Type == EST_Dynamic || - requiresFunctionProtoTypeArmAttributes() || - FunctionEffects; + requiresFunctionProtoTypeArmAttributes() || FunctionEffects; } bool requiresFunctionProtoTypeArmAttributes() const { @@ -7984,7 +7983,7 @@ public: const FunctionDecl &NewFunction, FunctionEffectSet NewFX) const; - /// Return true if adding or removing the effect in a C++ virtual method + /// Return true if adding or removing the effect in a C++ virtual method /// override should generate a diagnostic. virtual bool diagnoseMethodOverride(bool Adding, const CXXMethodDecl &OldMethod, @@ -7994,7 +7993,7 @@ public: /// Return true if the effect is allowed to be inferred on the specified Decl /// (may be a FunctionDecl or BlockDecl). Only used if the effect has - /// kInferrableOnCallees flag set. Example: This allows nolock(false) to + /// kInferrableOnCallees flag set. Example: This allows nolock(false) to /// prevent inference for the function. virtual bool canInferOnDecl(const Decl *Caller, FunctionEffectSet CallerFX) const; diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 43fccb117a..68f2ac3e13 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -4502,13 +4502,12 @@ QualType ASTContext::getFunctionTypeInternal( size_t Size = FunctionProtoType::totalSizeToAlloc< QualType, SourceLocation, FunctionType::FunctionTypeExtraBitfields, FunctionType::FunctionTypeArmAttributes, FunctionType::ExceptionType, - Expr *, FunctionDecl *, FunctionProtoType::ExtParameterInfo, + Expr *, FunctionDecl *, FunctionProtoType::ExtParameterInfo, FunctionEffectSet, Qualifiers>( NumArgs, EPI.Variadic, EPI.requiresFunctionProtoTypeExtraBitfields(), EPI.requiresFunctionProtoTypeArmAttributes(), ESH.NumExceptionType, ESH.NumExprPtr, ESH.NumFunctionDeclPtr, - EPI.ExtParameterInfos ? NumArgs : 0, - EPI.FunctionEffects ? 1 : 0, + EPI.ExtParameterInfos ? NumArgs : 0, EPI.FunctionEffects ? 1 : 0, EPI.TypeQuals.hasNonFastQualifiers() ? 1 : 0); auto *FTP = (FunctionProtoType *)Allocate(Size, alignof(FunctionProtoType)); @@ -10440,8 +10439,10 @@ QualType ASTContext::mergeFunctionTypes(QualType lhs, QualType rhs, FunctionEffectSet FromFX, ToFX; std::optional<FunctionEffectSet> MergedFX; - if (lproto) ToFX = lproto->getFunctionEffects(); - if (rproto) FromFX = rproto->getFunctionEffects(); + if (lproto) + ToFX = lproto->getFunctionEffects(); + if (rproto) + FromFX = rproto->getFunctionEffects(); if (ToFX != FromFX) { // We want the intersection of the effects... MergedFX = FunctionEffectSet::create(FromFX & ToFX); @@ -10499,8 +10500,10 @@ QualType ASTContext::mergeFunctionTypes(QualType lhs, QualType rhs, } if (!MergedFX) { // effects changed so we can't return either side unaltered - if (allLTypes) return lhs; - if (allRTypes) return rhs; + if (allLTypes) + return lhs; + if (allRTypes) + return rhs; } FunctionProtoType::ExtProtoInfo EPI = lproto->getExtProtoInfo(); @@ -10543,8 +10546,10 @@ QualType ASTContext::mergeFunctionTypes(QualType lhs, QualType rhs, } if (!MergedFX) { // effects changed so we can't return either side unaltered - if (allLTypes) return lhs; - if (allRTypes) return rhs; + if (allLTypes) + return lhs; + if (allRTypes) + return rhs; } FunctionProtoType::ExtProtoInfo EPI = proto->getExtProtoInfo(); diff --git a/clang/lib/Sema/AnalysisBasedWarnings.cpp b/clang/lib/Sema/AnalysisBasedWarnings.cpp index 69417b1004..bdc3aa9065 100644 --- a/clang/lib/Sema/AnalysisBasedWarnings.cpp +++ b/clang/lib/Sema/AnalysisBasedWarnings.cpp @@ -3196,8 +3196,7 @@ private: CurrentCaller(CurrentCaller) {} // -- Entry point -- - void run() - { + void run() { // The target function itself may have some implicit code paths beyond the // body: member and base constructors and destructors. Visit these first. if (const auto *FD = dyn_cast<const FunctionDecl>(CurrentCaller.CDecl)) { @@ -3225,8 +3224,8 @@ private: // flags include the specified flag receive a diagnostic. \p Flag describes // the construct. void diagnoseLanguageConstruct(FunctionEffect::FlagBit Flag, DiagnosticID D, - SourceLocation Loc, const Decl *Callee = nullptr) - { + SourceLocation Loc, + const Decl *Callee = nullptr) { // If there are ANY declared verifiable effects holding the flag, store // just one diagnostic. for (auto *Effect : CurrentFunction.DeclaredVerifiableEffects) { @@ -3247,8 +3246,8 @@ private: void addDiagnosticInner(bool Inferring, const FunctionEffect *Effect, DiagnosticID D, SourceLocation Loc, const Decl *Callee = nullptr) { - CurrentFunction.checkAddDiagnostic(Inferring, - Diagnostic(Effect, D, Loc, Callee)); + CurrentFunction.checkAddDiagnostic(Inferring, + Diagnostic(Effect, D, Loc, Callee)); } // Here we have a call to a Decl, either explicitly via a CallExpr or some @@ -3334,14 +3333,14 @@ private: bool shouldWalkTypesOfTypeLocs() const { return false; } bool VisitCXXThrowExpr(CXXThrowExpr *Throw) { - diagnoseLanguageConstruct(FunctionEffect::kExcludeThrow, DiagnosticID::Throws, - Throw->getThrowLoc()); + diagnoseLanguageConstruct(FunctionEffect::kExcludeThrow, + DiagnosticID::Throws, Throw->getThrowLoc()); return Proceed; } bool VisitCXXCatchStmt(CXXCatchStmt *Catch) { - diagnoseLanguageConstruct(FunctionEffect::kExcludeCatch, DiagnosticID::Catches, - Catch->getCatchLoc()); + diagnoseLanguageConstruct(FunctionEffect::kExcludeCatch, + DiagnosticID::Catches, Catch->getCatchLoc()); return Proceed; } @@ -3394,7 +3393,8 @@ private: if (Var->isStaticLocal()) { diagnoseLanguageConstruct(FunctionEffect::kExcludeStaticLocalVars, - DiagnosticID::HasStaticLocal, Var->getLocation()); + DiagnosticID::HasStaticLocal, + Var->getLocation()); } const QualType::DestructionKind DK = @@ -3493,7 +3493,8 @@ private: // At least on macOS, thread-local variables are initialized on // first access. diagnoseLanguageConstruct(FunctionEffect::kExcludeThreadLocalVars, - DiagnosticID::AccessesThreadLocal, E->getLocation()); + DiagnosticID::AccessesThreadLocal, + E->getLocation()); } } return Proceed; @@ -3770,7 +3771,7 @@ void clang::sema::AnalysisBasedWarnings::IssueWarnings( } // TODO: skip this if the warning isn't enabled. - FXAnalysis::Analyzer{ S }.run(*TU); + FXAnalysis::Analyzer{S}.run(*TU); } void clang::sema::AnalysisBasedWarnings::IssueWarnings( diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index 39d9eeac43..2872314b0c 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -681,7 +681,8 @@ ExprResult Sema::ImpCastExprToType(Expr *E, QualType Ty, diagnoseNullableToNonnullConversion(Ty, E->getType(), E->getBeginLoc()); diagnoseZeroToNullptrConversion(Kind, E); - if (!isCast(CCK) && !E->isNullPointerConstant(Context, Expr::NPC_NeverValueDependent /* ???*/)) { + if (!isCast(CCK) && !E->isNullPointerConstant( + Context, Expr::NPC_NeverValueDependent /* ???*/)) { diagnoseFunctionEffectConversion(Ty, E->getType(), E->getBeginLoc()); } diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index f437db5661..d407018adf 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -3923,28 +3923,30 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *&OldD, Scope *S, } const auto OldFX = Old->getFunctionEffects(); - const auto NewFX = New->getFunctionEffects(); + const auto NewFX = New->getFunctionEffects(); if (OldFX != NewFX) { const auto Diffs = FunctionEffectSet::differences(OldFX, NewFX); - for (const auto& Item : Diffs) { - const FunctionEffect* Effect = Item.first; + for (const auto &Item : Diffs) { + const FunctionEffect *Effect = Item.first; const bool Adding = Item.second; if (Effect->diagnoseRedeclaration(Adding, *Old, OldFX, *New, NewFX)) { - Diag(New->getLocation(), diag::warn_mismatched_func_effect_redeclaration) << Effect->name(); + Diag(New->getLocation(), + diag::warn_mismatched_func_effect_redeclaration) + << Effect->name(); Diag(Old->getLocation(), diag::note_previous_declaration); } } const auto MergedFX = OldFX | NewFX; - // Having diagnosed any problems, prevent further errors by applying the merged set of effects - // to both declarations. - auto applyMergedFX = [&](FunctionDecl* FD) { + // Having diagnosed any problems, prevent further errors by applying the + // merged set of effects to both declarations. + auto applyMergedFX = [&](FunctionDecl *FD) { const auto *FPT = FD->getType()->getAs<FunctionProtoType>(); FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo(); EPI.FunctionEffects = MergedFX; QualType ModQT = Context.getFunctionType(FD->getReturnType(), - FPT->getParamTypes(), EPI); + FPT->getParamTypes(), EPI); FD->setType(ModQT); }; @@ -11136,8 +11138,7 @@ Attr *Sema::getImplicitCodeSegOrSectionAttrForFunction(const FunctionDecl *FD, // Should only be called when getFunctionEffects() returns a non-empty set. // Decl should be a FunctionDecl or BlockDecl. -void Sema::CheckAddCallableWithEffects(const Decl *D, FunctionEffectSet FX) -{ +void Sema::CheckAddCallableWithEffects(const Decl *D, FunctionEffectSet FX) { if (!D->hasBody()) { if (const auto *FD = D->getAsFunction()) { if (!FD->willHaveBody()) { @@ -11148,7 +11149,7 @@ void Sema::CheckAddCallableWithEffects(const Decl *D, FunctionEffectSet FX) if (Diags.getIgnoreAllWarnings() || (Diags.getSuppressSystemWarnings() && - SourceMgr.isInSystemHeader(D->getLocation()))) + SourceMgr.isInSystemHeader(D->getLocation()))) return; if (hasUncompilableErrorOccurred()) diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index fd27ccd5c1..7805922c66 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -398,8 +398,7 @@ bool Sema::checkStringLiteralArgumentAttr(const ParsedAttr &AL, unsigned ArgNum, /// Check if the argument \p ArgNum of \p Attr is a compile-time constant /// integer (boolean) expression. If not, emit an error and return false. bool Sema::checkBoolExprArgumentAttr(const ParsedAttr &AL, unsigned ArgNum, - bool &Value) -{ + bool &Value) { if (AL.isInvalid()) { return false; } @@ -411,7 +410,7 @@ bool Sema::checkBoolExprArgumentAttr(const ParsedAttr &AL, unsigned ArgNum, ErrorLoc = IL->Loc; } else if (ArgExpr != nullptr) { if (const std::optional<llvm::APSInt> MaybeVal = - ArgExpr->getIntegerConstantExpr(Context, &ErrorLoc)) { + ArgExpr->getIntegerConstantExpr(Context, &ErrorLoc)) { Value = MaybeVal->getBoolValue(); return true; } @@ -419,7 +418,7 @@ bool Sema::checkBoolExprArgumentAttr(const ParsedAttr &AL, unsigned ArgNum, AL.setInvalid(); Diag(ErrorLoc, diag::err_attribute_argument_n_type) - << AL << ArgNum << AANT_ArgumentConstantExpr; + << AL << ArgNum << AANT_ArgumentConstantExpr; return false; } diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 7533d3f905..2f9a4a1415 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -18329,11 +18329,12 @@ bool Sema::CheckOverridingFunctionAttributes(const CXXMethodDecl *New, const auto Diffs = FunctionEffectSet::differences(OldFX, NewFX); bool AnyDiags = false; - for (const auto& Item : Diffs) { - const FunctionEffect* Effect = Item.first; + for (const auto &Item : Diffs) { + const FunctionEffect *Effect = Item.first; const bool Adding = Item.second; if (Effect->diagnoseMethodOverride(Adding, *Old, OldFX, *New, NewFX)) { - Diag(New->getLocation(), diag::warn_mismatched_func_effect_override) << Effect->name(); + Diag(New->getLocation(), diag::warn_mismatched_func_effect_override) + << Effect->name(); Diag(Old->getLocation(), diag::note_overridden_virtual_function); AnyDiags = true; } diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 50007d4e1d..e698139e55 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -4951,7 +4951,8 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType, // TODO: This generates a redundant diagnostic for: // void (^nl_block0)() NOLOCK = ^(){}; - // if (!From->isNullPointerConstant(Context, Expr::NPC_NeverValueDependent /* ???*/)) + // if (!From->isNullPointerConstant(Context, Expr::NPC_NeverValueDependent + // /* ???*/)) // diagnoseFunctionEffectConversion(ToType, InitialFromType, // From->getBeginLoc()); } diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 8f1563e788..1b6ed49faa 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -1879,10 +1879,11 @@ bool Sema::IsFunctionConversion(QualType FromType, QualType ToType, auto FromFX = FromFPT->getFunctionEffects(); auto ToFX = ToFPT->getFunctionEffects(); if (FromFX != ToFX) { - llvm::outs() << "IsFunctionConversion effects change " << FromType << " -> " << ToType << "\n"; + llvm::outs() << "IsFunctionConversion effects change " << FromType + << " -> " << ToType << "\n"; - //const auto MergedFX = FunctionEffectSet::getIntersection(FromFX, ToFX); - // TODO: diagnose conflicts + // const auto MergedFX = FunctionEffectSet::getIntersection(FromFX, ToFX); + // TODO: diagnose conflicts FunctionProtoType::ExtProtoInfo ExtInfo = FromFPT->getExtProtoInfo(); ExtInfo.FunctionEffects = ToFX; `````````` </details> https://github.com/llvm/llvm-project/pull/84983 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits