[clang] 972f65a - [clang][NFC] Add documentation for `CastExpr::path()`. (#85623)

via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 20 07:39:29 PDT 2024


Author: martinboehme
Date: 2024-03-20T15:34:11+01:00
New Revision: 972f65a83f933b0f90cf975ef89452f4210e9b06

URL: https://github.com/llvm/llvm-project/commit/972f65a83f933b0f90cf975ef89452f4210e9b06
DIFF: https://github.com/llvm/llvm-project/commit/972f65a83f933b0f90cf975ef89452f4210e9b06.diff

LOG: [clang][NFC] Add documentation for `CastExpr::path()`. (#85623)

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.

Added: 
    

Modified: 
    clang/include/clang/AST/Expr.h

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index f9313f87be3800..6e153ebe024b42 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -3562,6 +3562,18 @@ class CastExpr : public Expr {
   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).
+  ///
+  /// 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.
   llvm::iterator_range<path_iterator> path() {
     return llvm::make_range(path_begin(), path_end());
   }


        


More information about the cfe-commits mailing list