Skip to content

Commit a0ce3e6

Browse files
committed
[C++20] [Modules] Avoid crash with calls to (this auto) syntax
Due to we didn't consider (this, auto) information when setting abbrev for calls, we use incorrect format for calls, which cause crashes. From #118137
1 parent 0512d11 commit a0ce3e6

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

clang/lib/Serialization/ASTWriterStmt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ void ASTStmtWriter::VisitCallExpr(CallExpr *E) {
971971
Record.push_back(E->getFPFeatures().getAsOpaqueInt());
972972

973973
if (!E->hasStoredFPFeatures() && !static_cast<bool>(E->getADLCallKind()) &&
974-
E->getStmtClass() == Stmt::CallExprClass)
974+
!E->usesMemberSyntax() && E->getStmtClass() == Stmt::CallExprClass)
975975
AbbrevToUse = Writer.getCallExprAbbrev();
976976

977977
Code = serialization::EXPR_CALL;

clang/test/Modules/pr118137.cppm

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// RUN: rm -rf %t
2+
// RUN: mkdir -p %t
3+
// RUN: split-file %s %t
4+
//
5+
// RUN: %clang_cc1 -std=c++23 %t/a.cppm -emit-module-interface -o %t/a.pcm
6+
// RUN: %clang_cc1 -std=c++23 %t/a.cppm -emit-reduced-module-interface -o %t/a.pcm
7+
// RUN: %clang_cc1 -std=c++23 %t/a.cppm -emit-llvm -o -
8+
9+
//--- a.h
10+
typedef int nghttp2_session_callbacks;
11+
12+
//--- a.cppm
13+
module;
14+
#include "a.h"
15+
export module g;
16+
template <typename, typename T>
17+
concept Deleter = requires(T ptr) { ptr; };
18+
template <typename T, Deleter<T>> struct Handle {
19+
void GetRaw(this auto);
20+
};
21+
struct SessionCallbacksDeleter
22+
: Handle<nghttp2_session_callbacks, SessionCallbacksDeleter> {
23+
} Server_callbacks;
24+
void Server() { Server_callbacks.GetRaw(); }

0 commit comments

Comments
 (0)