[PATCH] D36101: Fix usage of right shift operator in fold expressions
Nicolas Lesser via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 31 05:55:37 PDT 2017
Rakete1111 updated this revision to Diff 120966.
Rakete1111 added a comment.
Used Parser's `GreaterThanIsOperator` just to be sure. :)
https://reviews.llvm.org/D36101
Files:
include/clang/Parse/Parser.h
lib/Parse/ParseExpr.cpp
test/Parser/cxx1z-fold-expressions.cpp
Index: test/Parser/cxx1z-fold-expressions.cpp
===================================================================
--- test/Parser/cxx1z-fold-expressions.cpp
+++ test/Parser/cxx1z-fold-expressions.cpp
@@ -43,3 +43,8 @@
(int)(undeclared_junk + ...) + // expected-error {{undeclared}}
(int)(a + ...); // expected-error {{does not contain any unexpanded}}
}
+
+// fold-operator can be '>' or '>>'.
+template<int ...N> bool greater_than() { return (N > ...); }
+template<int ...N> bool right_shift() { return (N >> ...); }
+
Index: lib/Parse/ParseExpr.cpp
===================================================================
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -266,11 +266,12 @@
return false;
}
-static bool isFoldOperator(prec::Level Level) {
+bool Parser::isFoldOperator(prec::Level Level) const {
return Level > prec::Unknown && Level != prec::Conditional;
}
-static bool isFoldOperator(tok::TokenKind Kind) {
- return isFoldOperator(getBinOpPrecedence(Kind, false, true));
+
+bool Parser::isFoldOperator(tok::TokenKind Kind) const {
+ return isFoldOperator(getBinOpPrecedence(Kind, GreaterThanIsOperator, true));
}
/// \brief Parse a binary expression that starts with \p LHS and has a
Index: include/clang/Parse/Parser.h
===================================================================
--- include/clang/Parse/Parser.h
+++ include/clang/Parse/Parser.h
@@ -506,6 +506,12 @@
Kind == tok::annot_module_end || Kind == tok::annot_module_include;
}
+ /// \brief Checks if the \p Level is valid for use in a fold expression.
+ bool isFoldOperator(prec::Level Level) const;
+
+ /// \brief Checks if the \p Kind is a valid operator for fold expressions.
+ bool isFoldOperator(tok::TokenKind Kind) const;
+
/// \brief Initialize all pragma handlers.
void initializePragmaHandlers();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36101.120966.patch
Type: text/x-patch
Size: 1855 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171031/5228bef6/attachment.bin>
More information about the cfe-commits
mailing list