diff --git a/clang/include/clang/AST/ExprConcepts.h b/clang/include/clang/AST/ExprConcepts.h --- a/clang/include/clang/AST/ExprConcepts.h +++ b/clang/include/clang/AST/ExprConcepts.h @@ -126,7 +126,11 @@ } SourceLocation getEndLoc() const LLVM_READONLY { - return ArgsAsWritten->RAngleLoc; + // If the ConceptSpecializationExpr is the ImmediatelyDeclaredConstraint + // of a TypeConstraint written syntactically as a constrained-parameter, + // there may not be a template argument list. + return ArgsAsWritten->RAngleLoc.isValid() ? ArgsAsWritten->RAngleLoc + : ConceptName.getEndLoc(); } // Iterators diff --git a/clang/test/AST/ast-dump-concepts.cpp b/clang/test/AST/ast-dump-concepts.cpp --- a/clang/test/AST/ast-dump-concepts.cpp +++ b/clang/test/AST/ast-dump-concepts.cpp @@ -6,14 +6,22 @@ // RUN: -ast-dump-all -ast-dump-filter Foo /dev/null \ // RUN: | FileCheck --strict-whitespace %s +template +concept unary_concept = true; + template concept binary_concept = true; template struct Foo { // CHECK: TemplateTypeParmDecl {{.*}} referenced Concept {{.*}} 'binary_concept' - // CHECK-NEXT: |-ConceptSpecializationExpr {{.*}} 'bool' + // CHECK-NEXT: |-ConceptSpecializationExpr {{.*}} 'bool' // CHECK-NEXT: `-TemplateArgument {{.*}} type 'int' template R> Foo(R); + + // CHECK: TemplateTypeParmDecl {{.*}} referenced Concept {{.*}} 'unary_concept' + // CHECK-NEXT: `-ConceptSpecializationExpr {{.*}} 'bool' + template + Foo(R); };