[clang] [APINotes] Add Where.Object selectors for C++ methods (PR #216148)

John Hui via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 17 01:10:57 PDT 2026


================
@@ -1008,47 +1008,170 @@ struct Context {
 
 using IdentifierID = llvm::PointerEmbeddedInt<unsigned, 31>;
 
+/// Describes the C++ implicit-object ref-qualifier portion of a method
+/// selector.
+enum class FunctionObjectRefQualifier : uint8_t {
+  None,
+  LValue,
+  RValue,
+};
+
+/// Describes optional constraints on a C++ method's implicit object parameter.
+struct FunctionObjectSelector {
+  std::optional<bool> Const;
+  std::optional<bool> Volatile;
+  std::optional<FunctionObjectRefQualifier> Ref;
+};
+
+inline bool operator==(const FunctionObjectSelector &LHS,
+                       const FunctionObjectSelector &RHS) {
+  return LHS.Const == RHS.Const && LHS.Volatile == RHS.Volatile &&
+         LHS.Ref == RHS.Ref;
+}
+
+inline bool operator!=(const FunctionObjectSelector &LHS,
+                       const FunctionObjectSelector &RHS) {
+  return !(LHS == RHS);
+}
+
+inline std::string formatAPINotesObjectSelector(FunctionObjectSelector Object) {
----------------
j-hui wrote:

This feels like it could be a (`const`-qualified) method of `FunctionObjectSelector`, and same with `formatAPINotesFunctionSelector`.

Though maybe this follows an established pattern. In any case, this can be cleaned up later.

https://github.com/llvm/llvm-project/pull/216148


More information about the cfe-commits mailing list