Author: Nathan Ridge
Date: 2020-07-29T02:44:26-04:00
New Revision: 89247792c5bdd58500b0e6c5e56532424c2e2ca1

URL: 
https://github.com/llvm/llvm-project/commit/89247792c5bdd58500b0e6c5e56532424c2e2ca1
DIFF: 
https://github.com/llvm/llvm-project/commit/89247792c5bdd58500b0e6c5e56532424c2e2ca1.diff

LOG: [clang] Fix ConceptSpecializationExpr::getEndLoc()

Summary:
It returned an invalid location in case of a constrained-parameter
with no explicit arguments.

Reviewers: hokein

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D84613

Added: 
    

Modified: 
    clang/include/clang/AST/ExprConcepts.h
    clang/test/AST/ast-dump-concepts.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/AST/ExprConcepts.h 
b/clang/include/clang/AST/ExprConcepts.h
index 2a88ed5175d2..1544c498ef66 100644
--- a/clang/include/clang/AST/ExprConcepts.h
+++ b/clang/include/clang/AST/ExprConcepts.h
@@ -126,7 +126,11 @@ class ConceptSpecializationExpr final : public Expr, 
public ConceptReference,
   }
 
   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
index 530c1baeffa7..3429fa6b46be 100644
--- 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 <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);
 };


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to