llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) <details> <summary>Changes</summary> Fix capitalization, define `AlignOfReturnsPreferred` only once it's needed and fix the parameter name comment for `getDeclAlign()`. The latter is also done in `ExprConstant.cpp`. --- Full diff: https://github.com/llvm/llvm-project/pull/232193.diff 2 Files Affected: - (modified) clang/lib/AST/ByteCode/Compiler.cpp (+7-8) - (modified) clang/lib/AST/ExprConstant.cpp (+2-2) ``````````diff diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index 6ba5099a78b87..e65aeeed55146 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -2805,11 +2805,8 @@ bool Compiler<Emitter>::VisitEmbedExpr(const EmbedExpr *E) { return this->visit(*It); } -static CharUnits AlignOfType(QualType T, const ASTContext &ASTCtx, +static CharUnits alignOfType(QualType T, const ASTContext &ASTCtx, UnaryExprOrTypeTrait Kind) { - bool AlignOfReturnsPreferred = - ASTCtx.getLangOpts().isCompatibleWith(LangOptions::ClangABI::Ver7); - // C++ [expr.alignof]p3: // When alignof is applied to a reference type, the result is the // alignment of the referenced type. @@ -2819,6 +2816,8 @@ static CharUnits AlignOfType(QualType T, const ASTContext &ASTCtx, if (T.getQualifiers().hasUnaligned()) return CharUnits::One(); + bool AlignOfReturnsPreferred = + ASTCtx.getLangOpts().isCompatibleWith(LangOptions::ClangABI::Ver7); // __alignof is defined to return the preferred alignment. // Before 8, clang returned the preferred alignment for alignof and // _Alignof as well. @@ -2901,7 +2900,7 @@ bool Compiler<Emitter>::VisitUnaryExprOrTypeTraitExpr( if (E->isArgumentType()) { QualType ArgType = E->getTypeOfArgument(); - Size = AlignOfType(ArgType, ASTCtx, Kind); + Size = alignOfType(ArgType, ASTCtx, Kind); } else { // Argument is an expression, not a type. const Expr *Arg = E->getArgumentExpr()->IgnoreParens(); @@ -2917,12 +2916,12 @@ bool Compiler<Emitter>::VisitUnaryExprOrTypeTraitExpr( // default to 1 in those cases. if (const auto *DRE = dyn_cast<DeclRefExpr>(Arg)) Size = ASTCtx.getDeclAlign(DRE->getDecl(), - /*RefAsPointee*/ true); + /*ForAlignOf=*/true); else if (const auto *ME = dyn_cast<MemberExpr>(Arg)) Size = ASTCtx.getDeclAlign(ME->getMemberDecl(), - /*RefAsPointee*/ true); + /*ForAlignOf=*/true); else - Size = AlignOfType(Arg->getType(), ASTCtx, Kind); + Size = alignOfType(Arg->getType(), ASTCtx, Kind); } if (DiscardResult) diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 87909992a46d5..e98313a4b52ea 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -10625,11 +10625,11 @@ CharUnits GetAlignOfExpr(const ASTContext &Ctx, const Expr *E, // to 1 in those cases. if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) return Ctx.getDeclAlign(DRE->getDecl(), - /*RefAsPointee*/ true); + /*ForAlignOf=*/true); if (const MemberExpr *ME = dyn_cast<MemberExpr>(E)) return Ctx.getDeclAlign(ME->getMemberDecl(), - /*RefAsPointee*/ true); + /*ForAlignOf=*/true); return GetAlignOfType(Ctx, E->getType(), ExprKind); } `````````` </details> https://github.com/llvm/llvm-project/pull/232193 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
