https://github.com/martinboehme updated https://github.com/llvm/llvm-project/pull/85623
>From 369410916bd61671f81702c4654bd48bfc3c6c53 Mon Sep 17 00:00:00 2001 From: Martin Braenne <mboe...@google.com> Date: Mon, 18 Mar 2024 09:51:23 +0000 Subject: [PATCH 1/3] [clang][NFC] Add documentation for `CastExpr::path()`. This didn't have any documentation, so I had to do some experimenting in godbolt when I used this in https://github.com/llvm/llvm-project/pull/84138, and my reviewer later also had some [questions](https://github.com/llvm/llvm-project/pull/84138#discussion_r1524855434) about this, so I figured it would be worth adding documentation. --- clang/include/clang/AST/Expr.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h index 446bec4081e869..8c4db4828477d0 100644 --- a/clang/include/clang/AST/Expr.h +++ b/clang/include/clang/AST/Expr.h @@ -3552,6 +3552,15 @@ class CastExpr : public Expr { /// function that it invokes. NamedDecl *getConversionFunction() const; + /// Path through the class hierarchy taken by a `DerivedToBase` or + /// `UncheckedDerivedToBase` cast. For each derived-to-base edge in the path, + /// the path contains a `CXXBaseSpecifier` for the base class of that edge; + /// the entries are ordered from derived class to base class. + /// + /// For example, given classes `Base`, `Intermediate : public Base` and + /// `Derived : public Intermediate`, the path for a cast from `Derived *` to + /// `Base *` contains two entries: One for `Intermediate`, and one for `Base`, + /// in that order. typedef CXXBaseSpecifier **path_iterator; typedef const CXXBaseSpecifier *const *path_const_iterator; bool path_empty() const { return path_size() == 0; } >From 571d5f4b180b2e55b03a4a43a7c0fadbee2ed25a Mon Sep 17 00:00:00 2001 From: Martin Braenne <mboe...@google.com> Date: Tue, 19 Mar 2024 07:30:39 +0000 Subject: [PATCH 2/3] fixup! [clang][NFC] Add documentation for `CastExpr::path()`. --- clang/include/clang/AST/Expr.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h index 8c4db4828477d0..292cda39dc56bf 100644 --- a/clang/include/clang/AST/Expr.h +++ b/clang/include/clang/AST/Expr.h @@ -3552,10 +3552,13 @@ class CastExpr : public Expr { /// function that it invokes. NamedDecl *getConversionFunction() const; - /// Path through the class hierarchy taken by a `DerivedToBase` or - /// `UncheckedDerivedToBase` cast. For each derived-to-base edge in the path, - /// the path contains a `CXXBaseSpecifier` for the base class of that edge; - /// the entries are ordered from derived class to base class. + /// Path through the class hierarchy taken by casts between base and derived + /// classes (see implementation of `CastConsistency()` for a full list of + /// cast kinds that have a path). + /// + /// For each derived-to-base edge in the path, the path contains a + /// `CXXBaseSpecifier` for the base class of that edge; the entries are + /// ordered from derived class to base class. /// /// For example, given classes `Base`, `Intermediate : public Base` and /// `Derived : public Intermediate`, the path for a cast from `Derived *` to >From 806ee8eab73a61867cb7cf305762aa4755bd20f4 Mon Sep 17 00:00:00 2001 From: Martin Braenne <mboe...@google.com> Date: Tue, 19 Mar 2024 10:36:11 +0000 Subject: [PATCH 3/3] fixup! fixup! [clang][NFC] Add documentation for `CastExpr::path()`. --- clang/include/clang/AST/Expr.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h index 292cda39dc56bf..a76404b3138dda 100644 --- a/clang/include/clang/AST/Expr.h +++ b/clang/include/clang/AST/Expr.h @@ -3552,6 +3552,15 @@ class CastExpr : public Expr { /// function that it invokes. NamedDecl *getConversionFunction() const; + typedef CXXBaseSpecifier **path_iterator; + typedef const CXXBaseSpecifier *const *path_const_iterator; + bool path_empty() const { return path_size() == 0; } + unsigned path_size() const { return CastExprBits.BasePathSize; } + path_iterator path_begin() { return path_buffer(); } + path_iterator path_end() { return path_buffer() + path_size(); } + path_const_iterator path_begin() const { return path_buffer(); } + path_const_iterator path_end() const { return path_buffer() + path_size(); } + /// Path through the class hierarchy taken by casts between base and derived /// classes (see implementation of `CastConsistency()` for a full list of /// cast kinds that have a path). @@ -3564,15 +3573,6 @@ class CastExpr : public Expr { /// `Derived : public Intermediate`, the path for a cast from `Derived *` to /// `Base *` contains two entries: One for `Intermediate`, and one for `Base`, /// in that order. - typedef CXXBaseSpecifier **path_iterator; - typedef const CXXBaseSpecifier *const *path_const_iterator; - bool path_empty() const { return path_size() == 0; } - unsigned path_size() const { return CastExprBits.BasePathSize; } - path_iterator path_begin() { return path_buffer(); } - path_iterator path_end() { return path_buffer() + path_size(); } - path_const_iterator path_begin() const { return path_buffer(); } - path_const_iterator path_end() const { return path_buffer() + path_size(); } - llvm::iterator_range<path_iterator> path() { return llvm::make_range(path_begin(), path_end()); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits