[clang] [Clang][Interp] Fix display of syntactically-invalid note for member function calls (PR #102170)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 8 08:19:39 PDT 2024
================
@@ -198,11 +198,11 @@ def NoRet : Opcode {}
def Call : Opcode {
- let Args = [ArgFunction, ArgUint32];
+ let Args = [ArgFunction, ArgUint32, ArgExpr];
----------------
yronglin wrote:
Thanks for your guidance! I've try in my local, it' caused 6 test failures.
```diff
diff --git a/clang/lib/AST/Interp/InterpFrame.cpp b/clang/lib/AST/Interp/InterpFrame.cpp
index 1d285dfb5f62..36c5b586564f 100644
--- a/clang/lib/AST/Interp/InterpFrame.cpp
+++ b/clang/lib/AST/Interp/InterpFrame.cpp
@@ -172,8 +172,9 @@ void InterpFrame::describe(llvm::raw_ostream &OS) const {
F && (F->isBuiltin() || F->isLambdaStaticInvoker()))
return;
+ const auto *MyCE = S.Current->Caller->getExpr(S.Current->getRetPC());
const FunctionDecl *F = getCallee();
- if (const auto *MCE = dyn_cast_if_present<CXXMemberCallExpr>(CallExpr)) {
+ if (const auto *MCE = dyn_cast_if_present<CXXMemberCallExpr>(MyCE)) {
const Expr *Object = MCE->getImplicitObjectArgument();
Object->printPretty(OS, /*Helper=*/nullptr, S.getCtx().getPrintingPolicy(),
/*Indentation=*/0);
@@ -182,7 +183,7 @@ void InterpFrame::describe(llvm::raw_ostream &OS) const {
else
OS << ".";
} else if (const auto *OCE =
- dyn_cast_if_present<CXXOperatorCallExpr>(CallExpr)) {
+ dyn_cast_if_present<CXXOperatorCallExpr>(MyCE)) {
OCE->getArg(0)->printPretty(OS, /*Helper=*/nullptr,
S.getCtx().getPrintingPolicy(),
/*Indentation=*/0);```
```console
Failed Tests (6):
Clang :: AST/Interp/arrays.cpp
Clang :: AST/Interp/constexpr-nqueens.cpp
Clang :: AST/Interp/cxx20.cpp
Clang :: AST/Interp/lambda.cpp
Clang :: AST/Interp/records.cpp
Clang :: SemaCXX/constexpr-frame-describe.cpp
```
```C++
constexpr int div(int a, int b) {
auto f = [=]() {
return a / b; // both-note {{division by zero}}
};
return f(); // expected-note {{in call to 'f.operator()()'}} \
// ref-note {{in call to 'f.operator()()'}}
}
static_assert(div(8, 2) == 4);
static_assert(div(8, 0) == 4); // both-error {{not an integral constant expression}} \
// both-note {{in call to 'div(8, 0)'}}
```
```console
error: 'both-note' diagnostics expected but not seen:
File /Users/yrong/Developer/Toolchain/llvm/trunk/llvm-project/clang/test/AST/Interp/lambda.cpp Line 53: in call to 'div(8, 0)'
error: 'both-note' diagnostics seen but not expected:
File /Users/yrong/Developer/Toolchain/llvm/trunk/llvm-project/clang/test/AST/Interp/lambda.cpp Line 53: in call to 'f.div(8, 0)'
2 errors generated.
```
Seems it's found an incorrect CallExpr.
https://github.com/llvm/llvm-project/pull/102170
More information about the cfe-commits
mailing list