[PATCH] D140756: Add clang_CXXMethod_isExplicit to libclang
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 13 06:24:32 PST 2023
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.
LGTM aside from some minor things you can correct when landing.
================
Comment at: clang/bindings/python/clang/cindex.py:1550-1557
+ class Foo {
+ explicit Foo();
+ explicit operator int();
+ };
+
+ This method will return 0 when given a cursor pointing to one of
+ the former declarations and it will return 1 for a cursor pointing
----------------
You might want to add documentation about:
```
constexpr bool foo(int i) { return i % 2 == 0; }
struct S {
explicit(foo(1)) S(); // IsExplicit returns false
explicit(foo(2)) operator int(); // IsExplicit returns true
```
so it's not about the syntactic element of there being an `explicit`, it's about what it resolves to.
================
Comment at: clang/include/clang-c/Index.h:4364
+ *
+ * class Foo {
+ * explicit Foo();
----------------
Same doc suggestions around here as in the Python code.
================
Comment at: clang/tools/libclang/CIndex.cpp:8951-8957
+ const CXXConstructorDecl *Constructor =
+ D ? dyn_cast_or_null<CXXConstructorDecl>(D->getAsFunction()) : nullptr;
+ const CXXConversionDecl *ConversionFunction =
+ D ? dyn_cast_or_null<CXXConversionDecl>(D->getAsFunction()) : nullptr;
+
+ return ((Constructor && Constructor->isExplicit()) ||
+ (ConversionFunction && ConversionFunction->isExplicit()));
----------------
Same logic, but spelled differently.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D140756/new/
https://reviews.llvm.org/D140756
More information about the cfe-commits
mailing list