nridge created this revision. nridge added a reviewer: hokein. Herald added a project: clang. Herald added a subscriber: cfe-commits.
It returned an invalid location in case of a constrained-parameter with no explicit arguments. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D84613 Files: clang/include/clang/AST/ExprConcepts.h clang/test/AST/ast-dump-concepts.cpp Index: clang/test/AST/ast-dump-concepts.cpp =================================================================== --- clang/test/AST/ast-dump-concepts.cpp +++ 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 <typename T> +concept unary_concept = true; + template <typename T, typename U> concept not_same_as = true; @@ -10,4 +13,9 @@ // CHECK-NEXT: `-TemplateArgument {{.*}} type 'int' template <not_same_as<int> R> Foo(R) requires(true); + + // CHECK: TemplateTypeParmDecl {{.*}} referenced Concept {{.*}} 'unary_concept' + // CHECK-NEXT: `-ConceptSpecializationExpr {{.*}} <col:13> 'bool' + template <unary_concept R> + Foo(R); }; Index: clang/include/clang/AST/ExprConcepts.h =================================================================== --- clang/include/clang/AST/ExprConcepts.h +++ 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
Index: clang/test/AST/ast-dump-concepts.cpp =================================================================== --- clang/test/AST/ast-dump-concepts.cpp +++ 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 <typename T> +concept unary_concept = true; + template <typename T, typename U> concept not_same_as = true; @@ -10,4 +13,9 @@ // CHECK-NEXT: `-TemplateArgument {{.*}} type 'int' template <not_same_as<int> R> Foo(R) requires(true); + + // CHECK: TemplateTypeParmDecl {{.*}} referenced Concept {{.*}} 'unary_concept' + // CHECK-NEXT: `-ConceptSpecializationExpr {{.*}} <col:13> 'bool' + template <unary_concept R> + Foo(R); }; Index: clang/include/clang/AST/ExprConcepts.h =================================================================== --- clang/include/clang/AST/ExprConcepts.h +++ 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
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits