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 @@ -1,5 +1,8 @@ // RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=c++2a -ast-dump -ast-dump-filter Foo %s | FileCheck -strict-whitespace %s +template +concept unary_concept = true; + template concept not_same_as = true; @@ -10,4 +13,9 @@ // CHECK-NEXT: `-TemplateArgument {{.*}} type 'int' template R> Foo(R) requires(true); + + // CHECK: TemplateTypeParmDecl {{.*}} referenced Concept {{.*}} 'unary_concept' + // CHECK-NEXT: `-ConceptSpecializationExpr {{.*}} 'bool' + template + Foo(R); };