[PATCH] D130303: Handle template parameter-dependent bit field widths in libclang

Collin Baker via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 6 12:56:39 PST 2023


collinbaker added inline comments.


================
Comment at: clang/include/clang-c/Index.h:3552
+ * If the cursor does not reference a bit field declaration or if the bit
+ * field's width does not depend on template parameters, 0 is returned.
+ */
----------------
vedgy wrote:
> I just thought how the new API could be used in KDevelop. Currently when `clang_getFieldDeclBitWidth()` is positive, e.g. 2, KDevelop shows  ` : 2` after the data member name in a tooltip. Ideally a template-param-dependent expression (actual code) would be displayed after the colon. If that's difficult to implement, `: [tparam-dependent]` or `: ?` could be displayed instead. But it would be more convenient and efficient to get this information by a single call to `clang_getFieldDeclBitWidth()` instead of calling `clang_isFieldDeclBitWidthDependent()` each time `clang_getFieldDeclBitWidth()` returns `-1`. So how about returning `-2` or `0` from `clang_getFieldDeclBitWidth()` instead of adding this new API?
I understand the motivation but I don't think requiring an extra call is asking too much of libclang clients, and it's one extra call that doesn't do much work and will be called rarely so I don't see efficiency concerns. Without strong reasons otherwise I think it's better to be explicit here.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130303/new/

https://reviews.llvm.org/D130303



More information about the cfe-commits mailing list