diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/ByteCode/InterpBuiltin.cpp | 4 | ||||
-rw-r--r-- | clang/lib/AST/DeclPrinter.cpp | 4 | ||||
-rw-r--r-- | clang/lib/CIR/CodeGen/CIRGenExprAggregate.cpp | 6 | ||||
-rw-r--r-- | clang/lib/Sema/SemaTemplate.cpp | 13 | ||||
-rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiate.cpp | 6 | ||||
-rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 18 |
6 files changed, 32 insertions, 19 deletions
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp index 6053237..68ebfdf 100644 --- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp +++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp @@ -2796,7 +2796,7 @@ static bool interp__builtin_ia32_pshuf(InterpState &S, CodePtr OpPC, unsigned LaneBase = (Idx / LaneElts) * LaneElts; unsigned LaneIdx = Idx % LaneElts; unsigned SrcIdx = Idx; - unsigned Sel = (Ctl >> (2 * LaneIdx)) & 0x3; + unsigned Sel = (Ctl >> (2 * (LaneIdx & 0x3))) & 0x3; if (ElemBits == 32) { SrcIdx = LaneBase + Sel; } else { @@ -2805,8 +2805,6 @@ static bool interp__builtin_ia32_pshuf(InterpState &S, CodePtr OpPC, if (!IsShufHW && !InHigh) { SrcIdx = LaneBase + Sel; } else if (IsShufHW && InHigh) { - unsigned Rel = LaneIdx - HalfSize; - Sel = (Ctl >> (2 * Rel)) & 0x3; SrcIdx = LaneBase + HalfSize + Sel; } } diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp index 196057f..7001ade 100644 --- a/clang/lib/AST/DeclPrinter.cpp +++ b/clang/lib/AST/DeclPrinter.cpp @@ -1894,7 +1894,7 @@ void DeclPrinter::VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *TTP) { Out << TTP->getDeclName(); } - if (TTP->hasDefaultArgument()) { + if (TTP->hasDefaultArgument() && !TTP->defaultArgumentWasInherited()) { Out << " = "; TTP->getDefaultArgument().getArgument().print(Policy, Out, /*IncludeType=*/false); @@ -1909,7 +1909,7 @@ void DeclPrinter::VisitNonTypeTemplateParmDecl( Policy.CleanUglifiedParameters ? II->deuglifiedName() : II->getName(); printDeclType(NTTP->getType(), Name, NTTP->isParameterPack()); - if (NTTP->hasDefaultArgument()) { + if (NTTP->hasDefaultArgument() && !NTTP->defaultArgumentWasInherited()) { Out << " = "; NTTP->getDefaultArgument().getArgument().print(Policy, Out, /*IncludeType=*/false); diff --git a/clang/lib/CIR/CodeGen/CIRGenExprAggregate.cpp b/clang/lib/CIR/CodeGen/CIRGenExprAggregate.cpp index e51c3fc..60ccf18 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExprAggregate.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExprAggregate.cpp @@ -201,8 +201,10 @@ public: } void VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *e) { - cgf.cgm.errorNYI(e->getSourceRange(), - "AggExprEmitter: VisitDesignatedInitUpdateExpr"); + AggValueSlot dest = ensureSlot(cgf.getLoc(e->getExprLoc()), e->getType()); + LValue destLV = cgf.makeAddrLValue(dest.getAddress(), e->getType()); + emitInitializationToLValue(e->getBase(), destLV); + VisitInitListExpr(e->getUpdater()); } void VisitAbstractConditionalOperator(const AbstractConditionalOperator *e) { cgf.cgm.errorNYI(e->getSourceRange(), diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index dcf2876..419f3e1 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -3822,14 +3822,19 @@ QualType Sema::CheckTemplateIdType(ElaboratedTypeKeyword Keyword, AliasTemplate->getTemplateParameters()->getDepth()); LocalInstantiationScope Scope(*this); - InstantiatingTemplate Inst( - *this, /*PointOfInstantiation=*/TemplateLoc, - /*Entity=*/AliasTemplate, - /*TemplateArgs=*/TemplateArgLists.getInnermost()); // Diagnose uses of this alias. (void)DiagnoseUseOfDecl(AliasTemplate, TemplateLoc); + // FIXME: The TemplateArgs passed here are not used for the context note, + // nor they should, because this note will be pointing to the specialization + // anyway. These arguments are needed for a hack for instantiating lambdas + // in the pattern of the alias. In getTemplateInstantiationArgs, these + // arguments will be used for collating the template arguments needed to + // instantiate the lambda. + InstantiatingTemplate Inst(*this, /*PointOfInstantiation=*/TemplateLoc, + /*Entity=*/AliasTemplate, + /*TemplateArgs=*/CTAI.SugaredConverted); if (Inst.isInvalid()) return QualType(); diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp index 1f762ca..7b05e4c 100644 --- a/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -1271,6 +1271,12 @@ void Sema::PrintInstantiationStack(InstantiationContextDiagFuncRef DiagFunc) { PDiag(diag::note_building_deduction_guide_here)); break; case CodeSynthesisContext::TypeAliasTemplateInstantiation: + // Workaround for a workaround: don't produce a note if we are merely + // instantiating some other template which contains this alias template. + // This would be redundant either with the error itself, or some other + // context note attached to it. + if (Active->NumTemplateArgs == 0) + break; DiagFunc(Active->PointOfInstantiation, PDiag(diag::note_template_type_alias_instantiation_here) << cast<TypeAliasTemplateDecl>(Active->Entity) diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index e2dc703..3819f77 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -1580,17 +1580,19 @@ Decl *TemplateDeclInstantiator::InstantiateTypeAliasTemplateDecl( if (!InstParams) return nullptr; - TypeAliasDecl *Pattern = D->getTemplatedDecl(); - Sema::InstantiatingTemplate InstTemplate( - SemaRef, D->getBeginLoc(), D, - D->getTemplateDepth() >= TemplateArgs.getNumLevels() - ? ArrayRef<TemplateArgument>() - : (TemplateArgs.begin() + TemplateArgs.getNumLevels() - 1 - - D->getTemplateDepth()) - ->Args); + // FIXME: This is a hack for instantiating lambdas in the pattern of the + // alias. We are not really instantiating the alias at its template level, + // that only happens in CheckTemplateId, this is only for outer templates + // which contain it. In getTemplateInstantiationArgs, the template arguments + // used here would be used for collating the template arguments needed to + // instantiate the lambda. Pass an empty argument list, so this workaround + // doesn't get confused if there is an outer alias being instantiated. + Sema::InstantiatingTemplate InstTemplate(SemaRef, D->getBeginLoc(), D, + ArrayRef<TemplateArgument>()); if (InstTemplate.isInvalid()) return nullptr; + TypeAliasDecl *Pattern = D->getTemplatedDecl(); TypeAliasTemplateDecl *PrevAliasTemplate = nullptr; if (getPreviousDeclForInstantiation<TypedefNameDecl>(Pattern)) { DeclContext::lookup_result Found = Owner->lookup(Pattern->getDeclName()); |