8000 clang: add upstream patch to fix assertion failure · yasuhirokimura/freebsd-src@ed2e3e5 · GitHub
[go: up one dir, main page]

Skip to content

Commit ed2e3e5

Browse files
author
Yasuhiro Kimura
committed
clang: add upstream patch to fix assertion failure
After devel/boost-libs is updated to 1.81.0, build fails on -CURRENT because of clang's assertion failure as following. clang-linux.compile.c++ bin.v2/libs/url/build/clang-linux-16/release/link-static/pch-off/threading-multi/visibility-hidden/src.o "c++" -c -x c++ -fvisibility-inlines-hidden -m64 -pthread -O3 -Wall -fvisibility=hidden -Wno-inline -pipe -DLIBICONV_PLUG -fstack-protector-strong -fno-strict-aliasing -DLIBICONV_PLUG -std=gnu++17 -pipe -DLIBICONV_PLUG -fstack-protector-strong -fno-strict-aliasing -DBOOST_ALL_NO_LIB=1 -DBOOST_URL_SOURCE -DBOOST_URL_STATIC_LINK=1 -DNDEBUG -I"." -o "bin.v2/libs/url/build/clang-linux-16/release/link-static/pch-off/threading-multi/visibility-hidden/src.o" "libs/url/src/src.cpp" Assertion failed: (isa<To>(Val) && "cast<Ty>() argument of incompatible type!"), function cast, file /usr/src/contrib/llvm-project/llvm/include/llvm/Support/Casting.h, line 579. PLEASE submit a bug report to https://bugs.freebsd.org/submit/ and include the crash backtrace, preprocessed source, and associated run script. Stack dump: 0. Program arguments: c++ -c -x c++ -fvisibility-inlines-hidden -m64 -pthread -O3 -Wall -fvisibility=hidden -Wno-inline -pipe -DLIBICONV_PLUG -fstack-protector-strong -fno-strict-aliasing -DLIBICONV_PLUG -std=gnu++17 -pipe -DLIBICONV_PLUG -fstack-protector-strong -fno-strict-aliasing -DBOOST_ALL_NO_LIB=1 -DBOOST_URL_SOURCE -DBOOST_URL_STATIC_LINK=1 -DNDEBUG -I. -o bin.v2/libs/url/build/clang-linux-16/release/link-static/pch-off/threading-multi/visibility-hidden/src.o libs/url/src/src.cpp 1. ./boost/url/impl/segments_view.ipp:33:1: current parser token '{' 2. ./boost/url/impl/segments_view.ipp:17:1: parsing namespace 'boost' 3. ./boost/url/impl/segments_view.ipp:18:1: parsing namespace 'boost::urls' #0 0x00000000058158c1 PrintStackTrace /usr/src/contrib/llvm-project/llvm/lib/Support/Unix/Signals.inc:567:13 freebsd#1 0x0000000005813c45 RunSignalHandlers /usr/src/contrib/llvm-project/llvm/lib/Support/Signals.cpp:105:18 freebsd#2 0x00000000057bb7cb HandleCrash /usr/src/contrib/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:73:5 freebsd#3 0x00000000057bb7cb CrashRecoverySignalHandler /usr/src/contrib/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:390:51 freebsd#4 0x000000082a4a9a8f handle_signal /usr/src/lib/libthr/thread/thr_sig.c:0:3 freebsd#5 0x000000082a4a904b thr_sighandler /usr/src/lib/libthr/thread/thr_sig.c:247:1 freebsd#6 0x000000082802a2d3 ([vdso]+0x2d3) freebsd#7 0x000000082e2a3cda thr_kill /usr/obj/usr/src/amd64.amd64/lib/libc/thr_kill.S:4:0 freebsd#8 0x000000082e21d1f4 raise /usr/src/lib/libc/gen/raise.c:0:10 freebsd#9 0x000000082e2cd3b9 abort /usr/src/lib/libc/stdlib/abort.c:73:17 c++: error: clang frontend command failed with exit code 134 (use -v to see invocation) FreeBSD clang version 16.0.6 (https://github.com/llvm/llvm-project.git llvmorg-16.0.6-0-g7cbf1a259152) Target: x86_64-unknown-freebsd14.0 Thread model: posix InstalledDir: /usr/bin c++: note: diagnostic msg: ******************** PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: Preprocessed source(s) and associated run script(s) are located at: c++: note: diagnostic msg: /tmp/src-00f4ba.cpp c++: note: diagnostic msg: /tmp/src-00f4ba.sh c++: note: diagnostic msg: ******************** ...failed clang-linux.compile.c++ bin.v2/libs/url/build/clang-linux-16/release/link-static/pch-off/threading-multi/visibility-hidden/src.o... So add upstream patch to fix it. PR: 269067 Obtained from: https://reviews.llvm.org/D148474
1 parent 827d0e4 commit ed2e3e5

File tree

2 files changed

+29
-26
lines changed

2 files changed

+29
-26
lines changed

contrib/llvm-project/clang/lib/Sema/SemaInit.cpp

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4092,16 +4092,13 @@ static bool hasCopyOrMoveCtorParam(ASTContext &Ctx,
40924092
return Ctx.hasSameUnqualifiedType(ParmT, ClassT);
40934093
}
40944094

4095-
static OverloadingResult
4096-
ResolveConstructorOverload(Sema &S, SourceLocation DeclLoc,
4097-
MultiExprArg Args,
4098-
OverloadCandidateSet &CandidateSet,
4099-
QualType DestType,
4100-
DeclContext::lookup_result Ctors,
4101-
OverloadCandidateSet::iterator &Best,
4102-
bool CopyInitializing, bool AllowExplicit,
4103-
bool OnlyListConstructors, bool IsListInit,
4104-
bool SecondStepOfCopyInit = false) {
4095+
static OverloadingResult ResolveConstructorOverload(
4096+
Sema &S, SourceLocation DeclLoc, MultiExprArg Args,
4097+
OverloadCandidateSet &CandidateSet, QualType DestType,
4098+
DeclContext::lookup_result Ctors, OverloadCandidateSet::iterator &Best,
4099+
bool CopyInitializing, bool AllowExplicit, bool OnlyListConstructors,
4100+
bool IsListInit, bool RequireActualConstructor,
4101+
bool SecondStepOfCopyInit = false) {
41054102
CandidateSet.clear(OverloadCandidateSet::CSK_InitByConstructor);
41064103
CandidateSet.setDestAS(DestType.getQualifiers().getAddressSpace());
41074104

@@ -4164,7 +4161,7 @@ ResolveConstructorOverload(Sema &S, SourceLocation DeclLoc,
41644161
// Note: SecondStepOfCopyInit is only ever true in this case when
41654162
// evaluating whether to produce a C++98 compatibility warning.
41664163
if (S.getLangOpts().CPlusPlus17 && Args.size() == 1 &&
4167-
!SecondStepOfCopyInit) {
4164+
!RequireActualConstructor && !SecondStepOfCopyInit) {
41684165
Expr *Initializer = Args[0];
41694166
auto *SourceRD = Initializer->getType()->getAsCXXRecordDecl();
41704167
if (SourceRD && S.isCompleteType(DeclLoc, Initializer->getType())) {
@@ -4232,6 +4229,12 @@ static void TryConstructorInitialization(Sema &S,
42324229
return;
42334230
}
42344231

4232+
bool RequireActualConstructor =
4233+
!(Entity.getKind() != InitializedEntity::EK_Base &&
4234+
Entity.getKind() != InitializedEntity::EK_Delegating &&
4235+
Entity.getKind() !=
4236+
InitializedEntity::EK_LambdaToBlockConversionBlockElement);
4237+
42354238
// C++17 [dcl.init]p17:
42364239
// - If the initializer expression is a prvalue and the cv-unqualified
42374240
// version of the source type is the same class as the class of the
@@ -4241,11 +4244,7 @@ static void TryConstructorInitialization(Sema &S,
42414244
// class or delegating to another constructor from a mem-initializer.
42424245
// ObjC++: Lambda captured by the block in the lambda to block conversion
42434246
// should avoid copy elision.
4244-
if (S.getLangOpts().CPlusPlus17 &&
4245-
Entity.getKind() != InitializedEntity::EK_Base &&
4246-
Entity.getKind() != InitializedEntity::EK_Delegating &&
4247-
Entity.getKind() !=
4248-
InitializedEntity::EK_LambdaToBlockConversionBlockElement &&
4247+
if (S.getLangOpts().CPlusPlus17 && !RequireActualConstructor &&
42494248
UnwrappedArgs.size() == 1 && UnwrappedArgs[0]->isPRValue() &&
42504249
S.Context.hasSameUnqualifiedType(UnwrappedArgs[0]->getType(), DestType)) {
42514250
// Convert qualifications if necessary.
@@ -4293,11 +4292,10 @@ static void TryConstructorInitialization(Sema &S,
42934292
// If the initializer list has no elements and T has a default constructor,
42944293
// the first phase is omitted.
42954294
if (!(UnwrappedArgs.empty() && S.LookupDefaultConstructor(DestRecordDecl)))
4296-
Result = ResolveConstructorOverload(S, Kind.getLocation(), Args,
4297-
CandidateSet, DestType, Ctors, Best,
4298-
CopyInitialization, AllowExplicit,
4299-
/*OnlyListConstructors=*/true,
4300-
IsListInit);
4295+
Result = ResolveConstructorOverload(
4296+
S, Kind.getLocation(), Args, CandidateSet, DestType, Ctors, Best,
4297+
CopyInitialization, AllowExplicit,
4298+
/*OnlyListConstructors=*/true, IsListInit, RequireActualConstructor);
43014299
}
43024300

43034301
// C++11 [over.match.list]p1:
@@ -4307,11 +4305,10 @@ static void TryConstructorInitialization(Sema &S,
43074305
// elements of the initializer list.
43084306
if (Result == OR_No_Viable_Function) {
43094307
AsInitializerList = false;
4310-
Result = ResolveConstructorOverload(S, Kind.getLocation(), UnwrappedArgs,
4311-
CandidateSet, DestType, Ctors, Best,
4312-
10000 CopyInitialization, AllowExplicit,
4313-
/*OnlyListConstructors=*/false,
4314-
IsListInit);
4308+
Result = ResolveConstructorOverload(
4309+
S, Kind.getLocation(), UnwrappedArgs, CandidateSet, DestType, Ctors,
4310+
Best, CopyInitialization, AllowExplicit,
4311+
/*OnlyListConstructors=*/false, IsListInit, RequireActualConstructor);
43154312
}
43164313
if (Result) {
43174314
Sequence.SetOverloadFailure(
@@ -6776,6 +6773,7 @@ static ExprResult CopyObject(Sema &S,
67766773
S, Loc, CurInitExpr, CandidateSet, T, Ctors, Best,
67776774
/*CopyInitializing=*/false, /*AllowExplicit=*/true,
67786775
/*OnlyListConstructors=*/false, /*IsListInit=*/false,
6776+
/*RequireActualConstructor=*/false,
67796777
/*SecondStepOfCopyInit=*/true)) {
67806778
case OR_Success:
67816779
break;
@@ -6921,6 +6919,7 @@ static void CheckCXX98CompatAccessibleCopy(Sema &S,
69216919
S, Loc, CurInitExpr, CandidateSet, CurInitExpr->getType(), Ctors, Best,
69226920
/*CopyInitializing=*/false, /*AllowExplicit=*/true,
69236921
/*OnlyListConstructors=*/false, /*IsListInit=*/false,
6922+
/*RequireActualConstructor=*/false,
69246923
/*SecondStepOfCopyInit=*/true);
69256924

69266925
PartialDiagnostic Diag = S.PDiag(diag::warn_cxx98_compat_temp_copy)

contrib/llvm-project/clang/lib/Sema/SemaTemplateInstantiate.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,10 @@ void Sema::PrintInstantiationStack() {
790790
Diags.Report(Active->PointOfInstantiation,
791791
diag::note_template_nsdmi_here)
792792
<< FD << Active->InstantiationRange;
793+
} else if (ClassTemplateDecl *CTD = dyn_cast<ClassTemplateDecl>(D)) {
794+
Diags.Report(Active->PointOfInstantiation,
795+
diag::note_template_class_instantiation_here)
796+
<< CTD << Active->InstantiationRange;
793797
} else {
794798
Diags.Report(Active->PointOfInstantiation,
795799
diag::note_template_type_alias_instantiation_here)

0 commit comments

Comments
 (0)
0