Author: Erich Keane Date: 2023-01-25T06:01:44-08:00 New Revision: 228462f755f0d459882b19115c60e8872a057b25
URL: https://github.com/llvm/llvm-project/commit/228462f755f0d459882b19115c60e8872a057b25 DIFF: https://github.com/llvm/llvm-project/commit/228462f755f0d459882b19115c60e8872a057b25.diff LOG: Fix one of the regressions found in revert of concept sugaring It seems that the sugaring patches had some pretty significant interdependencies, and at least one issue exists that requires part of the concept-sugaring patch. I don't believe this to have anything to do with the increased compile-times that were seen, so hopefully this will fix our problems without further regressions. See https://reviews.llvm.org/rG12cb1cb3720de8d164196010123ce1a8901d8122 for discussion. Differential Revision: https://reviews.llvm.org/D142500 Added: clang/test/SemaTemplate/sugar-crashes.cpp Modified: clang/lib/Sema/SemaExprCXX.cpp Removed: ################################################################################ diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index e3eef9323b2f8..abf5a72e7308a 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -1483,13 +1483,14 @@ Sema::BuildCXXTypeConstructExpr(TypeSourceInfo *TInfo, // Otherwise, if the type contains a placeholder type, it is replaced by the // type determined by placeholder type deduction. DeducedType *Deduced = Ty->getContainedDeducedType(); - if (Deduced && isa<DeducedTemplateSpecializationType>(Deduced)) { + if (Deduced && !Deduced->isDeduced() && + isa<DeducedTemplateSpecializationType>(Deduced)) { Ty = DeduceTemplateSpecializationFromInitializer(TInfo, Entity, Kind, Exprs); if (Ty.isNull()) return ExprError(); Entity = InitializedEntity::InitializeTemporary(TInfo, Ty); - } else if (Deduced) { + } else if (Deduced && !Deduced->isDeduced()) { MultiExprArg Inits = Exprs; if (ListInitialization) { auto *ILE = cast<InitListExpr>(Exprs[0]); @@ -2016,7 +2017,8 @@ ExprResult Sema::BuildCXXNew(SourceRange Range, bool UseGlobal, // C++11 [dcl.spec.auto]p6. Deduce the type which 'auto' stands in for. auto *Deduced = AllocType->getContainedDeducedType(); - if (Deduced && isa<DeducedTemplateSpecializationType>(Deduced)) { + if (Deduced && !Deduced->isDeduced() && + isa<DeducedTemplateSpecializationType>(Deduced)) { if (ArraySize) return ExprError( Diag(*ArraySize ? (*ArraySize)->getExprLoc() : TypeRange.getBegin(), @@ -2030,7 +2032,7 @@ ExprResult Sema::BuildCXXNew(SourceRange Range, bool UseGlobal, AllocTypeInfo, Entity, Kind, Exprs); if (AllocType.isNull()) return ExprError(); - } else if (Deduced) { + } else if (Deduced && !Deduced->isDeduced()) { MultiExprArg Inits = Exprs; bool Braced = (initStyle == CXXNewExpr::ListInit); if (Braced) { diff --git a/clang/test/SemaTemplate/sugar-crashes.cpp b/clang/test/SemaTemplate/sugar-crashes.cpp new file mode 100644 index 0000000000000..fd0789d044e29 --- /dev/null +++ b/clang/test/SemaTemplate/sugar-crashes.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -verify %s +// expected-no-diagnostics + + +struct StringPiece { + template <typename T, + typename = decltype(T())> + StringPiece(T str) {} +}; + +void f(StringPiece utf8) {} + +struct S { +}; + +void G() { + const auto s = S{}; + StringPiece U{s}; +} + _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits