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

via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 18 02:56:27 PDT 2024


https://github.com/martinboehme created https://github.com/llvm/llvm-project/pull/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.


>From 369410916bd61671f81702c4654bd48bfc3c6c53 Mon Sep 17 00:00:00 2001
From: Martin Braenne <mboehme at google.com>
Date: Mon, 18 Mar 2024 09:51:23 +0000
Subject: [PATCH] [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; }



More information about the cfe-commits mailing list