This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG89247792c5bd: [clang] Fix ConceptSpecializationExpr::getEndLoc() (authored by nridge).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D84613/new/ 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 @@ -6,14 +6,22 @@ // RUN: -ast-dump-all -ast-dump-filter Foo /dev/null \ // RUN: | FileCheck --strict-whitespace %s +template <typename T> +concept unary_concept = true; + template <typename T, typename U> concept binary_concept = true; template <typename T> struct Foo { // CHECK: TemplateTypeParmDecl {{.*}} referenced Concept {{.*}} 'binary_concept' - // CHECK-NEXT: |-ConceptSpecializationExpr {{.*}} 'bool' + // CHECK-NEXT: |-ConceptSpecializationExpr {{.*}} <col:13, col:31> 'bool' // CHECK-NEXT: `-TemplateArgument {{.*}} type 'int' template <binary_concept<int> R> Foo(R); + + // 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 @@ -6,14 +6,22 @@ // RUN: -ast-dump-all -ast-dump-filter Foo /dev/null \ // RUN: | FileCheck --strict-whitespace %s +template <typename T> +concept unary_concept = true; + template <typename T, typename U> concept binary_concept = true; template <typename T> struct Foo { // CHECK: TemplateTypeParmDecl {{.*}} referenced Concept {{.*}} 'binary_concept' - // CHECK-NEXT: |-ConceptSpecializationExpr {{.*}} 'bool' + // CHECK-NEXT: |-ConceptSpecializationExpr {{.*}} <col:13, col:31> 'bool' // CHECK-NEXT: `-TemplateArgument {{.*}} type 'int' template <binary_concept<int> R> Foo(R); + + // 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