[PATCH] D84613: [clang] Fix ConceptSpecializationExpr::getEndLoc()
Nathan Ridge via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Jul 26 19:50:27 PDT 2020
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84613.280770.patch
Type: text/x-patch
Size: 1496 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200727/ac438270/attachment-0001.bin>
More information about the cfe-commits
mailing list