[PATCH] D85645: [AST] Fix the CXXFoldExpr source range when parentheses range is invalid.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 12 00:21:02 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdc7b1e9db581: [AST] Fix the CXXFoldExpr source range when parentheses range is invalid. (authored by hokein).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D85645/new/
https://reviews.llvm.org/D85645
Files:
clang/include/clang/AST/ExprCXX.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
@@ -12,6 +12,9 @@
template <typename T, typename U>
concept binary_concept = true;
+template <typename... Ts>
+concept variadic_concept = true;
+
template <typename T>
struct Foo {
// CHECK: TemplateTypeParmDecl {{.*}} referenced Concept {{.*}} 'binary_concept'
@@ -37,4 +40,12 @@
template <typename R>
Foo(R, char) requires unary_concept<R> {
}
+
+ // CHECK: CXXFoldExpr {{.*}} <col:13, col:29>
+ template <variadic_concept... Ts>
+ Foo();
+
+ // CHECK: CXXFoldExpr {{.*}} <col:13, col:34>
+ template <variadic_concept<int>... Ts>
+ Foo();
};
Index: clang/include/clang/AST/ExprCXX.h
===================================================================
--- clang/include/clang/AST/ExprCXX.h
+++ clang/include/clang/AST/ExprCXX.h
@@ -4575,9 +4575,21 @@
return None;
}
- SourceLocation getBeginLoc() const LLVM_READONLY { return LParenLoc; }
+ SourceLocation getBeginLoc() const LLVM_READONLY {
+ if (LParenLoc.isValid())
+ return LParenLoc;
+ if (isLeftFold())
+ return getEllipsisLoc();
+ return getLHS()->getBeginLoc();
+ }
- SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
+ SourceLocation getEndLoc() const LLVM_READONLY {
+ if (RParenLoc.isValid())
+ return RParenLoc;
+ if (isRightFold())
+ return getEllipsisLoc();
+ return getRHS()->getEndLoc();
+ }
static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXFoldExprClass;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85645.284989.patch
Type: text/x-patch
Size: 1651 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200812/ca677837/attachment.bin>
More information about the cfe-commits
mailing list