[PATCH] D98095: [clang] Fix ICE on invalid type parameters for concepts
Richard Smith - zygoloid via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 8 13:03:55 PST 2021
rsmith added inline comments.
================
Comment at: clang/lib/Sema/SemaType.cpp:1644-1661
+ TemplateIdAnnotation *TemplateId = DS.getRepAsTemplateId();
+ ConceptDecl *TypeConstraintConcept = nullptr;
+ llvm::SmallVector<TemplateArgument, 8> TemplateArgs;
if (DS.isConstrainedAuto()) {
- Result = ConvertConstrainedAutoDeclSpecToType(S, DS,
- AutoTypeKeyword::Auto);
- break;
+ if (TemplateId) {
+ TypeConstraintConcept =
+ cast<ConceptDecl>(TemplateId->Template.get().getAsTemplateDecl());
----------------
Minor style nits: reduce scope of `TemplateId` variable and consistently brace the `else` if and only if the `if` is braced.
================
Comment at: clang/lib/Sema/SemaType.cpp:5947-5948
TL.setNameLoc(DS.getTypeSpecTypeLoc());
if (!DS.isConstrainedAuto())
return;
if (DS.getTypeSpecScope().isNotEmpty())
----------------
Given that we recover from an invalid `TemplateId` by creating an unconstrained `AutoType`, it would be more consistent to skip filling in the `NestedNameSpecifierLoc` here in that case too. (That way, we would populate the `NestedNameSpecifierLoc` if and only if we created a constrained `AutoType`.) I think it doesn't matter right now because no-one should look at this information for an unconstrained `AutoType`, but I could imagine we would switch to storing smaller `TypeLoc` data in the future if the type is unconstrained, and if we did, the writes to the `NestedNameSpecifierLoc` below would break.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D98095/new/
https://reviews.llvm.org/D98095
More information about the cfe-commits
mailing list