[clang] [Clang] Optimize some `getBeginLoc` implementations (PR #141058)
via cfe-commits
cfe-commits at lists.llvm.org
Thu May 22 06:04:12 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 HEAD~1 HEAD --extensions cpp,h -- clang/include/clang/AST/Expr.h clang/include/clang/AST/NestedNameSpecifier.h clang/include/clang/AST/Stmt.h clang/lib/AST/Expr.cpp clang/lib/AST/ExprCXX.cpp clang/lib/AST/NestedNameSpecifier.cpp clang/lib/Sema/SemaOpenCL.cpp clang/lib/Sema/SemaOverload.cpp clang/lib/Serialization/ASTReaderStmt.cpp clang/lib/Serialization/ASTWriterStmt.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 613a6e1e0..8f44f16ec 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -3217,11 +3217,11 @@ public:
SourceLocation getBeginLoc() const {
if (CallExprBits.HasTrailingSourceLoc) {
- assert(CallExprBits.HasTrailingSourceLoc && "No trailing source loc");
- static_assert(sizeof(CallExpr) <=
- offsetToTrailingObjects + sizeof(SourceLocation));
- return *reinterpret_cast<const SourceLocation *>(
- reinterpret_cast<const char *>(this) + sizeof(CallExpr));
+ assert(CallExprBits.HasTrailingSourceLoc && "No trailing source loc");
+ static_assert(sizeof(CallExpr) <=
+ offsetToTrailingObjects + sizeof(SourceLocation));
+ return *reinterpret_cast<const SourceLocation *>(
+ reinterpret_cast<const char *>(this) + sizeof(CallExpr));
}
if (usesMemberSyntax()) {
@@ -3232,9 +3232,7 @@ public:
return getCallee()->getBeginLoc();
}
- SourceLocation getEndLoc() const {
- return getRParenLoc();
- }
+ SourceLocation getEndLoc() const { return getRParenLoc(); }
private:
friend class ASTStmtReader;
``````````
</details>
https://github.com/llvm/llvm-project/pull/141058
More information about the cfe-commits
mailing list