[clang] Handle indexes (PR #130528)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Mar 9 17:09:20 PDT 2025
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 85d60a441ab810e25605fb4555971b1d0a996e5c 340c458523af7ab6a3228f2173a4e95b3f7b9d67 --extensions cpp -- clang/lib/AST/DeclCXX.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index ecba340f04..b0f0782555 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -2465,20 +2465,20 @@ CXXMethodDecl *CXXMethodDecl::getDevirtualizedMethod(const Expr *Base,
if (Base->isPRValue() && Base->getType()->isRecordType())
return this;
- // Handle array subscripts with constant indices when the pointee type is known
+ // Handle array subscripts with constant indices when the pointee type is
+ // known
if (const auto *ASE = dyn_cast<ArraySubscriptExpr>(Base)) {
QualType BaseTy = ASE->getBase()->getType();
-
+
// Check if it's a pointer to a record type
- if (BaseTy->isPointerType() &&
- BaseTy->getPointeeType()->isRecordType()) {
+ if (BaseTy->isPointerType() && BaseTy->getPointeeType()->isRecordType()) {
// For C++17 and later, we can devirtualize array access beyond p[0]
// According to [expr.add]/6, if the array element type and the pointee
// type are not similar, behavior is undefined, so we can assume they are
// the same type
const ASTContext &Context = getParent()->getASTContext();
const LangOptions &LangOpts = Context.getLangOpts();
- if (LangOpts.CPlusPlus17 &&
+ if (LangOpts.CPlusPlus17 &&
ASE->getIdx()->isIntegerConstantExpr(Context)) {
// It's a constant index, so it's safe to devirtualize
return this;
``````````
</details>
https://github.com/llvm/llvm-project/pull/130528
More information about the cfe-commits
mailing list