[clang] [Clang] Static and explicit object member functions with the same parameter-type-lists (PR #93430)
Hubert Tong via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 16 21:19:24 PDT 2024
================
@@ -5813,6 +5813,27 @@ static TypoCorrection TryTypoCorrectionForCall(Sema &S, Expr *Fn,
return TypoCorrection();
}
+// [C++26][[expr.unary.op]/p4
+// A pointer to member is only formed when an explicit &
+// is used and its operand is a qualified-id not enclosed in parentheses.
+static bool isParenthetizedAndQualifiedAddressOfExpr(Expr *Fn) {
+ if (!isa<ParenExpr>(Fn))
+ return false;
+
+ Fn = Fn->IgnoreParens();
+
+ auto *UO = dyn_cast<UnaryOperator>(Fn);
+ if (!UO || UO->getOpcode() != clang::UO_AddrOf)
+ return false;
+ if (auto *DRE = dyn_cast<DeclRefExpr>(UO->getSubExpr()->IgnoreParens())) {
+ assert(isa<FunctionDecl>(DRE->getDecl()) && "expected a function");
----------------
hubert-reinterpretcast wrote:
@cor3ntin, this assert is failing for a simple test (https://godbolt.org/z/Ye88sxfo8):
```cpp
int bar(void) { return 55; }
int (&fref)(void) = bar;
int main(void) {
return (&fref)();
}
```
https://github.com/llvm/llvm-project/pull/93430
More information about the cfe-commits
mailing list